package com.pug.order.config;

import com.pug.web.interceptor.HeaderContextInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author RenGaoshuai
 * @date 2023/7/6 15:27
 * @description 拦截器配置,不配置不生效（要在各个业务模块中配置）
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor headerContextInterceptor() {
        return new HeaderContextInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(headerContextInterceptor());
    }
}
